<template>
    <div class="on-sale-good-car">
        <div class="search-content">
            <div class="putaway-time-wrapper">
                <span class="member_name-label">会员名称：</span>
                <el-input class="search-content-input" v-model="searchContent.mname" placeholder="请输入会员名称"></el-input>
            </div>
			<div class="putaway-time-wrapper">
                <span class="member_name-label">添加时间：</span>
                <el-date-picker
                    v-model="searchContent.arrive_time"
					value-format="yyyy-MM-dd"
                    type="daterange"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期">
                </el-date-picker>
            </div>
			<el-select v-model="searchContent.stage" placeholder="操作阶段">
                <el-option
                    v-for="item in stageList"
                    :key="item.name"
                    :label="item.value"
                    :value="item.name">
                </el-option>
            </el-select>
            <div class="putaway-time-wrapper">
                <span class="member_name-label">操作店铺：</span>
                <el-input class="search-content-input" v-model="searchContent.store_name" placeholder="请输入操作店铺"></el-input>
            </div>
            <div class="putaway-time-wrapper">
                <span class="member_name-label">管理员名称：</span>
                <el-input class="search-content-input" v-model="searchContent.aname" placeholder="请输入管理员名称"></el-input>
            </div>  
            <div class="putaway-time-wrapper">
                <span class="member_name-label">描述：</span>
                <el-input class="search-content-input" v-model="searchContent.description" placeholder="请输入描述"></el-input>
            </div>
            <div class="putaway-time-wrapper">
                <span class="member_name-label">手机：</span>
                <el-input class="search-content-input" v-model="searchContent.pl_mobile" placeholder="请输入手机"></el-input>  
            </div>                             
            <el-button type="primary" @click="search">搜索</el-button>
            <el-button type="primary" @click="resetSearchData">重置</el-button>
        </div>        
        <div class="search-list">
            <el-table :data="pointsList" border :height="oHeight">
                <el-table-column align="center" type="selection" width="55">
                </el-table-column>
                <el-table-column
                    align="center"
                    prop="pl_id"
                    label="序号"
                    min-width="120"
                ></el-table-column>
                <el-table-column
                    align="center"
                    prop="pl_membername"
                    label="会员名称"
                    min-width="120"
                ></el-table-column>
                <el-table-column
                    align="center"
                    prop="pl_adminname"
                    label="管理员名称"
                    min-width="120"
                ></el-table-column>      
                <el-table-column
                    align="center"
                    prop="pl_points"
                    label="元宝值"
                    min-width="120"
                ></el-table-column>                            
                <el-table-column
                    align="center"
                    prop="pl_addtime"
                    label="添加时间"
                    min-width="120"
                >
                </el-table-column>
                <el-table-column
                    align="center"
                    prop="stage_name"
                    label="操作阶段"
                    min-width="120"
                ></el-table-column>  
                <el-table-column
                    align="center"
                    prop="pl_desc"
                    label="描述"
                    min-width="120"
                >
                </el-table-column>
                <el-table-column
                    align="center"
                    prop="store_name"
                    label="操作店铺"
                    min-width="120"
                >
                </el-table-column>

            <el-table-column
                fixed="right"
                align="center"
                label="操作"
                key="operate"
                width="120"
              >
                <template slot-scope="scope">
                <!-- review:0 未审核 review:1已审核 -->
                  <el-button
                    v-show="scope.row.pl_review && scope.row.pl_review == 1||scope.row.pl_review == 0"
                    class="operateBtn"
                    :disabled="scope.row.pl_review == 1"
                    type="text"
                    @click="reviewTable(scope.row.pl_id)"
                    >审核</el-button
                  >
                </template>
              </el-table-column>
            </el-table>
            <div class="bottom">
                <!--分页部分-->
                <div class="paginationOne">
                    <el-pagination
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="searchContent.curpage"
                        :page-sizes="[10, 20, 50, 100]"
                        :page-size="searchContent.eachNum"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="total"
                    >
                    </el-pagination>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import { resize } from "@/common/js/height.js";
import {dateFormatter} from "../../../../common/js/util"
export default {
    data() {
        return {
            pointsList: [],
            oHeight: 800,
            searchContent: {
                eachNum:localStorage.getItem('eachNum') * 1 || 10,
                curpage:1,
                description:'',
                pl_mobile:'',
                end_time:'',
                start_time:'',
                stage:'',
                store_name:'',
                aname:'',
                mname:'',
                arrive_time:''
            },
            arrive_time:'',
            stageList:[],
            searchObj:{},
			total:5000
        };
	},
	created(){
        this.getList();
        this.getStageName();
	},
    methods: {
      reviewTable(id){
          this.$http.post("/admin/member/index.php?act=pointManage&op=review",{pl_id:id}).then(res=>{
            if(res.code == 1){
                this.$message.success(res.msg);
                this.getList();
            }else{
                this.$message.error(res.msg);
            }
        })
      },
    reset_headers_params(row) {
                    // this.parameterForm
                    // {username:dsx,passwd:123}-----输入类型
                    // [{name:"username",value:"dsx"},{name:'passwd',value:'123'}]   ---输出类型
                    if (row) {
                        var params_data = []
                        var parameterObj =  row;               
                        for (var num in parameterObj) {
                            var params = {}
                            params['name'] = num
                            params['value'] = parameterObj[num]  //组装成对象
                            params_data.push(params) //添加到数组
                        }
                        this.parameterForm = params_data //初始化到parameterForm
                        return params_data;
                    } else {
                        this.form.params = undefined;
                        this.form.headers = undefined
                    }
                },         
		showFn(data){
			this.$refs.ceshi.show_dialog_fn(data);
		},
        expertData() {
            /* var host = location.host.replace('admin', api);
            var url = location.protocol + "//" + host + '/admin/appointment/index.php?act=appoint&op=appointList&is_export=1';
            var searchData = this.searchObj;
            for (var key in searchData) {
                if (!(searchData[key] === null || searchData[key] === '' || searchData[key] === undefined || key === 'page' || key === 'pageSize' || key === 'currentPage')) {
                    url += '&' + key + '=' + searchData[key]
                }
            }
            console.log(url);
            window.location.href = url; */
        },
        handleSizeChange(eachNum) {
            localStorage.setItem('eachNum', eachNum);
            this.searchContent.eachNum = eachNum;
            this.searchContent.page = 1;
            this.getList();
        },
        handleCurrentChange(curpage) {
            this.searchContent.curpage = curpage;
            this.getList();
        },
        // 重置
        resetSearchData() {
            this.searchContent={
                curpage:1,
                eachNum:localStorage.getItem('eachNum')*1||10,
            }
        },
        // 搜索
        search() {
            this.searchContent.curpage = 1;
            if(this.searchContent.arrive_time){
                this.searchContent.end_time = dateFormatter('YYYY-MM-DD 23:59:59', this.searchContent.arrive_time[1]);
                this.searchContent.start_time = dateFormatter('YYYY-MM-DD 00:00:00', this.searchContent.arrive_time[0]);
            }
            this.searchObj = {
                description:this.searchContent.description,
                pl_mobile:this.searchContent.pl_mobile,
                end_time:this.searchContent.end_time,
                start_time:this.searchContent.start_time,
                stage:this.searchContent.stage,
                store_name:this.searchContent.store_name,
                aname:this.searchContent.aname,
                mname:this.searchContent.mname,             
            }
            this.getList();
        },       
        getStageName(){
            this.$http.post('/admin/member/index.php?act=pointManage&op=getStageSelect','').then((res)=>{
                if(res.code == 1){
                    if(res.data){
                        this.stageList = this.reset_headers_params(res.data);
                        // console.log(this.stageList);
                    }
                }
            })
        }, 
        // 获取列表
		getList(){
            var data = this.searchObj;
            data.curpage = this.searchContent.curpage;
            data.eachNum = this.searchContent.eachNum;
            // console.log(data);
            this.$http.post('/admin/member/index.php?act=pointManage&op=list',data).then((res)=> {
                // console.log(res);
                if (res.code == 1) {
                  console.log(res,'res');
                    if (res.data.list && res.data.list.length) {
                        this.pointsList = res.data.list;
                    } else {
                        this.pointsList = [];
                        this.total = 0;
                    }
                }
                else if (res.code == 2001) {
                    this.pointsList = [];
                    this.total = 0;
                }
                else {
                    alert(res.msg);
                }
            })			
		}
    },
   
    mounted() {
        resize(this)
    },
};
</script>
<style lang="scss" scoped>
    .on-sale-good-car {
        .search-content {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            padding-left: 0;
            &-input {
                width: 200px;
            }
            .putaway-time-wrapper {
                display: flex;
                align-items: center;
                /deep/.el-range-separator {
                    box-sizing: content-box;
                }
            }
            .member_name-label {
                font-size: 14px;
                margin-left: 8px;
                color: #333;
            }
        }
    }
	.bottom{
		display: flex;
		justify-content: flex-end;
		align-items: center;
	}
</style>